<!--
  This file is a part of the open-eBackup project.
  This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
  If a copy of the MPL was not distributed with this file, You can obtain one at
  http://mozilla.org/MPL/2.0/.
  
  Copyright (c) [2024] Huawei Technologies Co.,Ltd.
  
  THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
  EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
  MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
  -->

<lv-form [formGroup]="formGroup" class="formGroup">
    <lv-form-item>
        <lv-form-label lvRequired>
            {{(isSshPort ? 'protection_agent_ssh_port_label' : 'common_port_label') | i18n}}
            <i lv-icon="aui-icon-help" lv-tooltip="{{'protection_register_agent_ports_label' | i18n}}"
                class="configform-constraint" lvTooltipPosition="rightTop"
                lvColorState='true'></i>
        </lv-form-label>
        <lv-form-control [lvErrorTip]="portErrorTip">
            <input type="text" formControlName="port" lv-input placeholder={{portTips}} />
        </lv-form-control>
    </lv-form-item>
    <lv-form-item *ngIf="isSshPort">
        <lv-form-label lvRequired>
            {{'protection_agent_sftp_port_label' | i18n}}
        </lv-form-label>
        <lv-form-control [lvErrorTip]="portErrorTip">
            <input type="text" formControlName='sftpPort' lv-input>
        </lv-form-control>
    </lv-form-item>
    <!-- 用户类型 -->
    <ng-container *ngIf="showUserType">
        <lv-form-item>
            <lv-form-label lvRequired>
                {{'common_user_type_label' | i18n}}
                <i lv-icon="aui-icon-help" class="configform-constraint"
                    lv-tooltip="{{'common_user_type_help_label' | i18n}}" lvTooltipPosition="rightTop"
                     lvColorState='true'></i>
            </lv-form-label>
            <lv-form-control>
                <lv-select [lvOptions]='userTypeOptions' lvValueKey='value' formControlName='userType'>
                </lv-select>
            </lv-form-control>
        </lv-form-item>
        <lv-form-item *ngIf="formGroup.value.userType === dataMap.userType.common.value">
            <lv-form-label lvRequired>
                {{'common_sudo_no_pwd_label' | i18n}}
                <i lv-icon="aui-icon-help" class="configform-constraint"
                    lv-tooltip="{{'common_sudo_no_pwd_tip_label' | i18n}}" lvTooltipPosition="rightTop"
                     lvColorState='true'></i>
            </lv-form-label>
            <lv-form-control>
                <lv-select [lvOptions]="passwordTypeOptions" lvValueKey='value'
                    formControlName='passwordType'></lv-select>
            </lv-form-control>
        </lv-form-item>
    </ng-container>
    <lv-form-item>
        <lv-form-label lvRequired>
            {{'common_username_label' | i18n}}
        </lv-form-label>
        <lv-form-control [lvErrorTip]="usernameErrorTip">
            <input type="text" formControlName="username" lv-input />
        </lv-form-control>
    </lv-form-item>
    <lv-form-item>
        <lv-form-label lvRequired>
            {{'common_password_label' | i18n}}
        </lv-form-label>
        <lv-form-control [lvErrorTip]="passwordErrorTip">
            <aui-inupt-with-eye formControlName="password"></aui-inupt-with-eye>
        </lv-form-control>
    </lv-form-item>
    <!-- sudo密码 -->
    <lv-form-item
        *ngIf="showUserType && formGroup.value.userType === dataMap.userType.common.value && !formGroup.value.passwordType">
        <lv-form-label lvRequired>
            {{'common_sudo_password_label' | i18n}}
        </lv-form-label>
        <lv-form-control [lvErrorTip]="passwordErrorTip">
            <aui-inupt-with-eye formControlName="sudoPassword"></aui-inupt-with-eye>
        </lv-form-control>
    </lv-form-item>
    <!-- 消息签名算法 -->
    <ng-container *ngIf="isSshPort">
        <lv-form-item>
            <lv-form-label lvRequired>
                {{'common_message_signature_algorithm_label'|i18n}}
                <i lv-icon="aui-icon-help" lv-tooltip="{{ 'common_help_signature_algorithm_label' | i18n }}"
                     lvTooltipPosition="right" class="configform-constraint"
                    lvColorState="true"></i>
            </lv-form-label>
            <lv-form-control>
                <lv-select [lvOptions]='thmsOptions' lvValueKey='value' formControlName='algorithms'
                    class="register-control">
                </lv-select>
                <ng-container *ngIf="formGroup.value.algorithms === dataMap.hmacSignatureAlgorithm.compatible.value">
                    <lv-group class="warn-tip-group" [lvColumns]='["16px", "auto"]'>
                        <i lv-icon="lv-icon-status-warning-info"></i>
                        <span class="aui-text-label algorithm-warn-label">
                            {{'common_message_algorithm_warn_label' | i18n}}
                        </span>
                    </lv-group>
                </ng-container>
            </lv-form-control>
        </lv-form-item>
    </ng-container>
</lv-form>
